/*
** my_ls.c for my_ls in /home/chassa_m/rendu/PSU_2013_my_ls
** 
** Made by chassa_m
** Login   <chassa_m@epitech.net>
** 
** Started on  Mon Nov 25 14:34:54 2013 chassa_m
** Last update Wed Nov 27 22:54:07 2013 chassa_m
*/

#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "jesus.h"

void	my_ls(char *path)
{
  DIR	*diropen;
  struct dirent	*dirread;
  struct jesus	*wala;

  if (path)
    diropen = opendir(path);
  else
    diropen = opendir(".");
  dirread = readdir(diropen);
  if (diropen == NULL)
    exit(write(2, "Unable to open directory.\n", 26));
  dirread = readdir(diropen);
  if (dirread == NULL)
    exit(write(2, "Unable to read directory.\n", 26));
  my_printf("%s%s", dirread->d_name, "\n");
  while ((dirread = readdir(diropen)) != NULL)
    {
      if (dirread->d_type == 4)
	my_printf("%s%s%s%s", "\033[34;1m", dirread->d_name, "\033[37;0m", "\n");
      else
	my_printf("%s%s", dirread->d_name, "\n");
      printf("%d\n", wala->size_t);
    }
  closedir(diropen);
}

int	main(int ac, char **av)
{
  my_ls(av[1]);
  return (0);
}
